Skip to content

Conversation

@michaldudak
Copy link
Owner

@michaldudak michaldudak commented May 26, 2025

If a conditional type is encountered, we consider both branches as possible values:

T extends S ? A : B generates a UnionNode with A and B as member types.

@michaldudak michaldudak requested a review from Copilot May 26, 2025 12:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves the handling of conditional types by treating them as unions in the type resolver and providing corresponding tests.

  • Adds new test cases in test/conditional-types (input.ts and output.json) to validate conditional types support
  • Updates src/parsers/typeResolver.ts to resolve conditional types by combining their true and false branches into a union node

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/conditional-types/output.json Introduces a JSON output describing conditional type exports
test/conditional-types/input.ts Provides test functions and components using conditional types
src/parsers/typeResolver.ts Refactors conditional type resolution to return union nodes for both branches

@pkg-pr-new
Copy link

pkg-pr-new bot commented May 26, 2025

Open in StackBlitz

npm i https://pkg.pr.new/typescript-api-extractor@1

commit: 980a687

@michaldudak michaldudak merged commit b1652d7 into main May 26, 2025
2 checks passed
@michaldudak michaldudak deleted the conditional-types branch May 27, 2025 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants